plasticContainer <- list(
greenBox=c("paper","scissor"), # location 1
redBox=c(1L,3L,2.5), # location 2
blueBox=c(TRUE,FALSE,TRUE,TRUE) # location 3
)
plasticContainer[c("greenBox","redBox")] # or plasticContainer[c(1,2)]
$`greenBox`
[1] "paper" "scissor"
$redBox
[1] 1.0 3.0 2.5
plasticContainer[c("greenBox")] # or plasticContainer[c(1,2)]
$`greenBox`
[1] "paper" "scissor"
plasticContainer[["greenBox"]] # or plasticContainer[[1]]
[1] "paper" "scissor"
plasticContainer$greenBox
[1] "paper" "scissor"
plasticContainer$greenBox[1]
[1] "paper"
plasticContainer[["greenBox"]][1]
[1] "paper"
plasticContainer["greenBox"][1]
$`greenBox`
[1] "paper" "scissor"
plasticContainer["greenBox"][2]
$<NA>
NULL
plasticContainer["greenBox"]$greenBox[1]
[1] "paper"
install.packages("plotly")
Error in install.packages : Updating loaded packages
library(readr)
download.file("https://github.com/tpemartin/github-data/blob/master/plotly_4070_neda.Rda?raw=true",destfile = "plotly_4070_neda.Rda")
trying URL 'https://github.com/tpemartin/github-data/blob/master/plotly_4070_neda.Rda?raw=true'
Content type 'application/octet-stream' length 12400 bytes (12 KB)
downloaded 12 KB
load("plotly_4070_neda.Rda")
Error in load("plotly_4070_neda.Rda") : error reading from connection
plotly_4070_neda[[2]]
Error: object 'plotly_4070_neda' not found
plotly_4070_neda$x$layout$shapes[[1]]$opacity<-0.8
plotly_4070_neda
library(readr)
Warning message:
In strsplit(code, "\n", fixed = TRUE) :
input string 1 is invalid in this locale
transcriptData <- read_csv("https://raw.githubusercontent.com/tpemartin/github-data/master/transcript100_102.csv",
col_types = cols(
學期成績="n"
))
totalCredits<-function(x){
transcriptData[transcriptData$學號==x,]->subsample
subsample %>%
mutate(
及格=(學期成績>=60)
) %>%
summarise(
學號=學號[1],
總修習學分數=sum(學分數),
總實得學分數=sum(學分數[及格])
)
}
transcriptData -> subsample
Warning message:
In strsplit(code, "\n", fixed = TRUE) :
input string 1 is invalid in this locale
subsample$學號 %>% unique -> 符合條件學號
#0
creditResults<-vector("list",length(符合條件學號))
Warning message:
In strsplit(code, "\n", fixed = TRUE) :
input string 1 is invalid in this locale
i<-1
#1
符合條件學號[i]
[1] "d55dP1052"
#2
totalCredits(符合條件學號[i])
#3
creditResults[[i]] <- totalCredits(符合條件學號[i])
for(i in seq_along(符合條件學號)){
creditResults[[i]] <- totalCredits(符合條件學號[i])
}
i<-200
creditResults[[200]]
library(readr)
library(tidyr)
libraryData <- read_csv("https://raw.githubusercontent.com/tpemartin/github-data/master/libraryData2.csv")
Parsed with column specification:
cols(
戼㹥Ǹ戼㸹 = col_character(),
愼㹥搼㸱挼㸴y挼㸳昼㹥愼㸷O = col_character(),
愼㹥搼㸱挼㸴y愼㸶W戼㹡搼㸹 = col_character(),
愼㹥搼㸱挼㸴y愼㸵X愼㹡愼㸹愼㸴攼㸹戼㸴挼㸱 = col_integer(),
愼㹥搼㸱挼㸴y挼㸰]挼㸲æa = col_character(),
愼㹥搼㸱挼㸴y愼㸴W愼㹣[愼㸶~愼㸴攼㹢 = col_date(format = ""),
愼㸴J戼㹥Ǧ~ = col_integer(),
Ū愼㹡̦~愼㹦挼㸵 = col_integer(),
戼㹥ǰ| = col_character(),
愼㹤ɾ\愼㹥ɶ愼㸱 = col_datetime(format = ""),
戼㹥Ǵ挼㸱 = col_integer(),
戼㹥Ǧ~ = col_integer(),
戼㹥Ǩt = col_character()
)
libraryData %>%
group_by(學院) %>%
nest
libraryDataNested
library(stringr)
library(dplyr)
df <- data.frame(
x = 1:3,
y = c("a", "d,e,f", "g,h"),
stringsAsFactors = F
)
df %>%
mutate(y = str_split(y, ",")) -> dfSplit